package jude.java.money.batch.bean;

import java.util.HashMap;
import java.util.Map;

import jude.java.util.Utils;

public class Site {

	public static final String KEY_TYPE = "type";				//网站类型
	public static final String KEY_51LA = "51la";				//51la统计代码
	public static final String KEY_RPPAY = "rppay";				//rppay站点ID
	public static final String KEY_GSPAY = "gspay";				//gspay站点ID
	public static final String KEY_BACKEND = "backend";			//后台路径
	public static final String KEY_ADMIN = "admin";				//用户名
	public static final String KEY_TEMPLATE = "zc_template";	//使用模板(zc)
	public static final String KEY_KEYWORD = "keyword";			//推广的关键字
	public static final String KEY_NEWS = "zc_news";			//新闻位置(zc)
	public static final String KEY_SPACE = "space";				//空间
	public static final String KEY_GMAIL = "gmail";				//google帐户, 网站管理员
	public static final String KEY_GV_CODE = "verification";	//google网站认证码
	public static final String KEY_REMARK = "remark";			//备注
	public static final String KEY_ECPSS = "ecpss";				//ecpss
	
	public static final String TYPE_ZENCART = "zencart";
	public static final String TYPE_MAGENTO = "magento";
	public static final String TYPE_WORDPRESS = "wordpress";
	
	public static final String NEWS_BOTTOM = "bottom";
	public static final String NEWS_SIDEBOX = "sidebox";
	public static final String NEWS_BOTH = "both";
	
	private String domain;
	
	private Map<String, String> attributes;
	private static final Map<String, String> defaultAttributes = new HashMap<String, String>();
	static {
		defaultAttributes.put(KEY_TYPE, TYPE_ZENCART);
//		defaultAttributes.put(KEY_BACKEND, "money");
//		defaultAttributes.put(KEY_ADMIN, "billgates");
//		defaultAttributes.put(KEY_NEWS, "none");
	}
	
	public Site() {
		this.attributes = new HashMap<String, String>();
	}
	
	public String getDomain() {
		return domain;
	}
	public void setDomain(String domain) {
		this.domain = domain;
	}
	
	
	public String getType() {
		return get(KEY_TYPE);
	}
	public void setType(String type) {
		set(KEY_TYPE, type);
	}
/*	public String getRppayId() {
		return get(KEY_RPPAY);
	}
	public void setRppayId(String rppaySiteId) {
		set(KEY_RPPAY, rppaySiteId);
	}
	public String getGspayId() {
		return get(KEY_GSPAY);
	}
	public void setGspayId(String gspaySiteId) {
		set(KEY_GSPAY, gspaySiteId);
	}
	public void setLa51(String la51) {
		set(KEY_51LA, la51);
	}
	public String getLa51() {
		return get(KEY_51LA);
	}
*/	
	public String get(String key) {
		String v = attributes.get(key);
		if (v == null)
			return defaultAttributes.get(key);
		return v;
	}
	
	public int getInt(String key) {
		return Utils.getInteger(get(key), 0);
	}
	
	public boolean has(String key) {
		return attributes.containsKey(key);
	}
	
	public void set(String key, String value) {
		String v = this.attributes.put(key, value);
		if (v != null) {
			System.out.println(key + " " + value + " [repeat] " + v);
		}
	}
	
//	public String getIP() {
//		return ip;
//	}
//	public void setIP(String ip) {
//		this.ip = ip;
//	}
}
